import torch
from torch import nn

import common
class vkmodel(nn.Module):
    def __init__(self):
        super(vkmodel, self).__init__()
        # kernel_size卷积层数 padding=边距填充
        self.layer1=nn.Sequential(
            nn.Conv2d(in_channels=1,out_channels=64, kernel_size=3,padding=1),#([1, 64, 30, 80 ])
            nn.ReLU(),
            nn.MaxPool2d(kernel_size=2)
        )
        self.layer2=nn.Sequential(
            nn.Conv2d(in_channels=64,out_channels=128, kernel_size=3,padding=1),#([1, 128, 15, 40])
            nn.ReLU(),
            nn.MaxPool2d(kernel_size=2)
        )
        self.layer3=nn.Sequential(
            nn.Conv2d(in_channels=128,out_channels=256, kernel_size=3,padding=1),#([1, 256, 7, 20])
            nn.ReLU(),
            nn.MaxPool2d(kernel_size=2)
        )
        self.layer4=nn.Sequential(
            nn.Conv2d(in_channels=256,out_channels=512, kernel_size=3,padding=1),#([1, 512, 3, 10])
            nn.ReLU(),
            nn.MaxPool2d(kernel_size=2)
        )
        self.layer5=nn.Sequential(
            nn.Flatten(),#[1, 15360]
            nn.Linear(in_features=15360,out_features=4096),
            nn.Dropout(0.2),
            nn.ReLU(),
            nn.Linear(in_features=4096, out_features=common.captcha_array.__len__()*common.captcha_size)
        )
        # 一直除下去，直到没得除


    def forward(self, x):
        x=self.layer1(x)
        x=self.layer2(x)
        x=self.layer3(x)
        x=self.layer4(x)
        x=self.layer5(x)
        return x

if __name__ == '__main__':
    data=torch.ones(1,1,60,160)
    m=vkmodel()
    x=m(data)
    print(x.shape)